var e = require("../../../api.js"), t = getApp(), n = require("../../../wxParse/wxParse.js");

Page({
    data: {
        current_data: 0,
        current_money_index: 0,
        current_money: "",
        current_id: "",
        runner: {
            bond_price: "0.00",
            bond_id: 1
        },
        getMoney: [ {
            id: 1,
            promise_money: "0.01",
            des: "<p>1232</p >",
            money: "20000.00",
            num: 100,
            name: "跑腿默认保证金1"
        }, {
            id: 2,
            promise_money: "0.01",
            des: "<p>1232</p >",
            money: "20000.00",
            num: 100,
            name: "跑腿默认保证金1"
        }, {
            id: 3,
            promise_money: "0.01",
            des: "<p>1232</p >",
            money: "20000.00",
            num: 100,
            name: "跑腿默认保证金1"
        }, {
            id: 4,
            promise_money: "0.01",
            des: "<p>1232</p >",
            money: "20000.00",
            num: 100,
            name: "跑腿默认保证金1"
        } ]
    },
    onLoad: function(a) {
        var r = this;
        t.request({
            url: e.promise_money.index,
            method: "post",
            data: {},
            success: function(e) {
                if (1 == e.code) {
                    var t = e.data;
                    console.log(t, "11111111111111"), r.setData({
                        getMoney: e.data,
                        runner: e.data.promise_money,
                        bind: e.data.hand
                        // bind: 0
                    }), n.wxParse("article", "html", e.data.des, r, 5);
                }
            }
        }), a.uid && t.shareCouponsMessage(a.uid);
    },
    pay: function() {
        var n = this.data.runner;
        t.request({
            url: e.driver.margin,
            data: {
                amount: n
            },
            method: "post",
            success: function(e) {
                1 == e.code ? wx.requestPayment({
                    timeStamp: e.data.timeStamp,
                    nonceStr: e.data.nonceStr,
                    package: e.data.package,
                    signType: "MD5",
                    paySign: e.data.paySign,
                    success: function(e) {
                        console.log("current_id", e), wx.redirectTo({
                            url: "/pages/index/index"
                        });
                    },
                    fail: function() {}
                }) : 0 === e.code ? wx.showToast({
                    title: e.msg,
                    icon: "none"
                }) : wx.showModal({
                    title: "提示",
                    content: "支付失败"
                });
            }
        });
    },
    outpay: function() {
        var n = this;
        wx.showModal({
            title: "提示",
            content: "您确定要退还押金？",
            success: function(a) {
                a.confirm && t.request({
                    url: e.driver.refund,
                    method: "post",
                    data: {
                        is_margin: 3,
                        amount: n.data.runner
                    },
                    success: function(e) {
                        console.log(e), 1 == e.code ? wx.showToast({
                            title: e.msg,
                            icon: "none",
                            duration: 3e3,
                            success: function() {
                                setTimeout(function() {
                                    wx.reLaunch({
                                        url: "/pages/map/driverServer/driverServer"
                                    });
                                }, 1e4);
                            }
                        }) : wx.showToast({
                            title: e.msg,
                            icon: "none",
                            success: function() {
                                setTimeout(function() {
                                    wx.reLaunch({
                                        url: "/pages/map/driverServer/driverServer"
                                    });
                                }, 1500);
                            }
                        });
                    }
                });
            }
        });
    },
    selectGetMoney: function(e) {
        var t = this;
        console.log("this is money id", e.currentTarget.dataset.id), t.setData({
            current_money: t.data.getMoney[e.currentTarget.dataset.selected],
            current_money_index: e.currentTarget.dataset.selected,
            current_id: e.currentTarget.dataset.id
        }), n.wxParse("article", "html", t.data.getMoney[e.currentTarget.dataset.selected].des, t, 5);
    },
    onReady: function() {},
    onShow: function() {},
    onShareAppMessage: function() {
        var e = t.shareAppMessage().title, n = t.shareAppMessage().imageUrl, a = t.shareAppMessage().desc, r = t.shareAppMessage().path;
        return console.log(t.shareAppMessage()), {
            title: e,
            imageUrl: n,
            desc: a,
            path: r
        };
    }
});